/*!
 *  菜单管理 通用（请求）方法
 *  
 * 作者：吴金龙 
 * Copyright (c) 2019/12/03
 * 
 */

/**
 * @method getMenuFuncSearch 查询菜单节点
 * @param {string} val 查询参数
 * @return axios
 */
export const getMenuFuncSearch = (val) => {
  return axios.get('/rbac/ccmsMenuFuncTree/menuFuncSearch?searchName=' + val)
}

/**
 * @method getAppAuth 获取顶级节点（应用节点）
 * @return axios
 */
export const getAppAuth = () => {
  return axios.get('/rbac/ccmsAppAuth/getAppAuth')
}

/**
 * @method getRootMenuFunc 获取菜单节点（根据应用id）
 * @param {string} appId 应用id
 * @return axios
 */
export const getRootMenuFunc = (appId) => {
  return axios.get(`/rbac/ccmsMenuFuncTree/getRootMenuFunc/${appId}`)
}

/**
 * @method getMenuFunChildren 获取菜单（功能）节点（根据菜单id）
 * @param {string} nodeId 菜单id
 * @return axios
 */
export const getMenuFunChildren = (nodeId) => {
  return axios.get(`/rbac/ccmsMenuFuncTree/children/${nodeId}`)
}

/**
 * @method getCcmsApps 获取应用详情（根据appId）
 * @param {string} appId 应用节点主键
 * @return axios
 */
export const getCcmsApps = (appId) => {
  return axios.get('/rbac/ccmsApps/' + appId)
}

/**
 * @method getMenuFuncCont 获取菜单详情（根据nodeId）
 * @param {string} nodeId 菜单和功能节点主键
 * @return axios
 */
export const getMenuFuncCont = (nodeId) => {
  return axios.get('/rbac/ccmsMenuFuncTree/' + nodeId)
}

/**
 * @method getNodeType 获取节点类型
 * @return axios
 */
export const getNodeType = () => {
  return axios.get('/base/dict/comboBoxData/f4903bc3e3aa4f9f9630cb41bdce952e')
}

/**
 * @method postMenuFun 保存菜单和功能
 * @param {object} data 节点字段项
 * @return axios
 */
export const postMenuFun = (data) => {
  return axios.post('/rbac/ccmsMenuFuncTree/svOrUp', data)
}

/**
 * @method postMenuFunNext 新增下级节点
 * @param {string} data 节点字段项
 * @return axios
 */
export const postMenuFunNext = (data) => {
  return axios.post('/rbac/ccmsMenuFuncTree/next', data)
}

/**
 * @method deleteMenuFun 删除节点
 * @param {string} nodeId 节点主键
 * @return axios
 */
export const deleteMenuFun = (nodeId) => {
  return axios.post('/rbac/ccmsMenuFuncTree/del', [{
    "nodeId": nodeId
  }])
}
